export function useTimeControl() {
  const worker = new ComlinkWorker<typeof import("@/workers/time")>(
    new URL("@/workers/time", import.meta.url)
  );

  // 时间同步逻辑
  const syncTime = async () => {
    const serverTime = await fetch("/api/time").then((r) => r.json());
    worker.synchronize(serverTime.timestamp);
  };

  // 速度控制
  const setSpeed = (multiplier: number) => {
    worker.setSpeed(multiplier);
  };

  return { syncTime, setSpeed };
}
